﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;

namespace ProAG_Tetris_WPF
{
    class PlayerCharacter
    {
        // UI 
        private Game Context
        {
            get;
            set;
        }
        public Rectangle PlayerRect
        {
            get;
            private set;
        }

        // Scope for Transform-Operations
        public enum Scope
        {
            Absolute,
            Relative
        }

        // X and Y Positions 
        public double XPos
        {
            get
            {
                return Canvas.GetLeft(PlayerRect);
            }
            set
            {
                if (value - 1 > 0 && value - 1 < Context.GameCanvas.Width - Width - 1)
                {
                    Canvas.SetLeft(PlayerRect, value);
                }
            }
        }
        public double YPos
        {
            get
            {
                return Canvas.GetTop(PlayerRect);
            }
            set
            {
                if (value - 1 > 0 && value - 1 < Context.GameCanvas.Height - Height)
                {
                    Canvas.SetTop(PlayerRect, value);
                }
            }
        }

        // Fill Color of PlayerRect
        public Brush Fill
        {
            get
            {
                return PlayerRect.Fill;
            }
            private set
            {
                PlayerRect.Fill = value;
            }
        }

        // Width and Height of PlayerRect
        public double Width
        {
            get
            {
                return PlayerRect.Width;
            }
            private set
            {
                PlayerRect.Width = value;
            }
        }
        public double Height
        {
            get
            {
                return PlayerRect.Height;
            }
            private set
            {
                PlayerRect.Height = value;
            }
        }

        public PlayerCharacter(Game context, Brush fill, double width, double height)
        {
            Context = context;
            PlayerRect = new Rectangle();
            Width = width;
            Height = height;
            Fill = fill;
        }

        public void Move(Scope moveType, double newXPos, double newYPos)
        {
            if (moveType == Scope.Absolute)
            {
                XPos = newXPos;
                YPos = newYPos;
            }
            else if (moveType == Scope.Relative)
            {
                XPos = XPos + newXPos;
                YPos = YPos + newYPos;
            }
        }
    }
}
